/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Quality_Daily_Report",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using ATkg.BizAppProject.DomainModels;
using ATkg.BizAppProject.IServices;
using Microsoft.AspNetCore.Authorization;

namespace ATkg.BizAppProject.Controllers
{
    [Route("api/[controller]/[action]")]
    public partial class Quality_Daily_ReportController
    {
        private readonly IQuality_Daily_ReportService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Quality_Daily_ReportController(
            IQuality_Daily_ReportService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        public class GetLocationWaveId
        {
            public string Location { get; set; }
            public string WaveId { get; set; }
        }

        public class QualityResultAdd
        {
            public int Id { get; set; }
            public string WaveId { get; set; }
            public string InspectionTime { get; set; }
            public string ProductId { get; set; }
            public string Grade { get; set; }
            public string Plating { get; set; }
            public string BlankLotName { get; set; }
            public string Spec { get; set; }
            public string AtmMonth { get; set; }
            public string ScheduleId { get; set; }
            public decimal OutgoingFinalQty { get; set; }
            public decimal IncomingQualifiedFinalQty { get; set; }

            public decimal DefectBlankQty { get; set; }

            public decimal DefectGrindingQty { get; set; }
            public decimal DefectPunchingQty { get; set; }
            public decimal DefectLinearQty { get; set; }
            public decimal DefectCuteQty { get; set; }
            public decimal DefectVariableQty { get; set; }
            public decimal DefectFringeQty { get; set; }
            public decimal DefectSliceQty { get; set; }
            public decimal DefectChamferQty { get; set; }
            public decimal DefectPlatingQty { get; set; }
            //
            public decimal DefectPermeationQty { get; set; }
            public decimal ReworkDefectQty { get; set; }
            public decimal ChipFinalQty { get; set; }
            public decimal DefectBlackFinalQty { get; set; }
            public decimal PlatingCheckFallQty { get; set; }
            public decimal MagnetizationFallQty { get; set; }
            public decimal SamplingReliabilityQty { get; set; }
            public decimal MaterialEbQty { get; set; }
            public decimal MaterialCrackQty { get; set; }
            public decimal MaterialDitQty { get; set; }
            //
            
            public decimal MaterialImpurityQty { get; set; }
            public decimal MaterialLightspotQty { get; set; }
            public decimal MaterialSiliconeOilQty { get; set; }
            public decimal MaterialFluxBadQty { get; set; }
            public decimal MaterialOxygenQty { get; set; }
            public decimal MaterialMiscQty { get; set; }
            public decimal DefectGrindingEbQty { get; set; }
            public decimal DefectGrindingProcessQty { get; set; }
            public decimal DefectPunchingEbQty { get; set; }
            public decimal DefectPunchingProcessQty { get; set; }
            public decimal DefectFringeEbQty { get; set; }
            public decimal DefectFringeProcessQty { get; set; }
            public decimal DefectLinearEbQty { get; set; }
            public decimal DefectLinearProcessQty { get; set; }
            public decimal DefectCuteEbQty { get; set; }
            public decimal DefectCuteProcessQty { get; set; }
            public decimal DefectVariableEbQty { get; set; }
            public decimal DefectVariableProcessQty { get; set; }
            public decimal DefectVariableVerticalityQty { get; set; }
            public decimal DefectVariablePitQty { get; set; }
            public decimal DefectSliceEbQty { get; set; }
            public decimal DefectSliceProcessQty { get; set; }
            public decimal DefectSliceMarkQty { get; set; }
            public decimal DefectSliceVerticalityQty { get; set; }
            public decimal DefectSliceSizeQty { get; set; }
            public decimal DefectSlicePitQty { get; set; }
            public decimal DefectChamferEbQty { get; set; }
            public decimal DefectChamferProcessQty { get; set; }
            public decimal DefectChamferPitQty { get; set; }
            public decimal DefectPlatingConcavePitQty { get; set; }
            public decimal DefectPlatingColordiffQty { get; set; }
            public decimal DefectPlatingSizeQty { get; set; }
            public decimal DefectPlatingFluxQty { get; set; }
            public decimal DefectPlatingEdgeBrokenQty { get; set; }
            public decimal DefectPlatingPaintQty { get; set; }
            public decimal DefectPlatingNetQty { get; set; }
            public decimal DefectPlatingForeignQty { get; set; }
            public decimal DefectPlatingBubbleQty { get; set; }
            public decimal DefectPlatingPitQty { get; set; }
            public decimal DefectPlatingDisabilityQty { get; set; }
            public decimal ReworkTestQty { get; set; }
            public decimal ReworkColordiffQty { get; set; }
            public decimal ReworkScratchQty { get; set; }
            public decimal ReworkBlisterQty { get; set; }
            public decimal ReworkOutoftolQty { get; set; }
            public decimal ReworkEdgeBrokenQty { get; set; }
            public decimal ReworkPitQty { get; set; }
            public decimal ReworkPaintQty { get; set; }
            public decimal ReworkForeignQty { get; set; }
            public decimal ReworkNetQty { get; set; }
            public decimal ReworkPlatingPaintQty { get; set; }


        }

        [HttpPost("SyncQualityDailyReport")]
        [AllowAnonymous]
        public async Task<JsonResult> SyncQualityDailyReport([FromBody] GetLocationWaveId getLocationWaveId)
        {
            string Location = getLocationWaveId.Location;
            string WaveId = getLocationWaveId.WaveId; 
            object r;
            if (Location == "空港")
            {
                r = await Service.SyncQualityDailyReport_KongGang(WaveId);//JCC1519
            }
            else if (Location == "爱科")
            {
                r = await Service.SyncQualityDailyReport_AiKe(WaveId);//JAT0905   ETB0030
            }
            else//北方  宁波
            {
                r = await Service.SyncQualityDailyReport_BeiFang(WaveId);//JAD0997
            }

            return JsonNormal(r);
        }
    }
}
